﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq.Mapping;
using System.ComponentModel;

namespace SMSAssistant.Model
{
    [Table(Name = "backup")]
    public class Backup : NotificationObject
    {
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int Id { get; set; }

        private DateTime? backupTime;
        [Column]
        public DateTime? BackupTime
        {
            get { return backupTime; }
            set
            {
                NotifyPropertyChanging("BackupTime");
                backupTime = value;
                NotifyPropertyChanged("BackupTime");
            }
        }

        public DateTime? BackupTimeLocal
        {
            get
            {
                if (backupTime.HasValue)
                    return backupTime.Value.ToLocalTime();
                else
                    return null;
            }
        }
        int messageCount;
        [Column]
        public int MessageCount
        {
            get { return messageCount; }
            set
            {
                NotifyPropertyChanging("MessageCount");
                messageCount = value;
                NotifyPropertyChanged("MessageCount");
            }
        }

        string backupFileUrl;
        [Column]
        public string BackupFileUrl
        {
            get { return backupFileUrl; }
            set
            {
                NotifyPropertyChanging("BackupFileUrl");
                backupFileUrl = value;
                NotifyPropertyChanged("BackupFileUrl");
            }
        }

        string fileID;
        [Column]
        public string FileID
        {
            get { return fileID; }
            set { fileID = value; }
        }

        public override string ToString()
        {
            if (BackupTime.HasValue)
            {
                return string.Format(Resources.Resource.BackupDisplayText, messageCount);
            }
            return base.ToString();
        }


    }
}
